/*
 * @Author: Zhouhai 497675647@qq.com
 * @Date: 2022-09-23 16:01:38
 * @LastEditors: Zhouhai 497675647@qq.com
 * @LastEditTime: 2023-03-03 15:58:02
 */
import { LoginInfo } from "@/type.d/login";
import { AjaxResult } from '@/type.d/ajaxResult.d'
import {encrypt} from "@/utils/jsencrypt";
import HTTPREQUEST from "@/servers/http";

// 登录方法
export function login(loginInfo: LoginInfo) {

  const password = loginInfo.password;
  loginInfo.password = encrypt(password ? password : '');

  return HTTPREQUEST.post("/login",loginInfo,{isToken: false});
}


// 获取用户详细信息
export function getInfo() {
  return HTTPREQUEST.get("/getInfo")
}

// 退出方法
export function logout() {
 return HTTPREQUEST.get("/logout")
}

export type CaptchaCode = AjaxResult & {
  captchaOnOff: boolean;
  uuid: string;
  img: string;
};

// 获取验证码
export function getCodeImg(): Promise<any & CaptchaCode> {
  return HTTPREQUEST.get("/captchaImage","",{isToken: false})
}
